package com.sichem.domain.activity.service.discount.impl;

import com.sichem.domain.activity.model.valobj.GroupBuyActivityDiscountVO;
import com.sichem.domain.activity.service.discount.AbstractDiscountCalculateService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;

/**
 * @Author xiangshizhen
 * @Date 2025/2/11
 * 折扣
 */
@Service("ZK")
@Slf4j
public class ZKCalculateService extends AbstractDiscountCalculateService {

    @Override
    protected BigDecimal doCalculate(BigDecimal originalPrice, GroupBuyActivityDiscountVO.GroupBuyDiscount groupBuyDiscount) {

        String marketExpr = groupBuyDiscount.getMarketExpr();

        // 计算满减后的金额
        BigDecimal deductionPrice = originalPrice.multiply(new BigDecimal(marketExpr));

        // 小于0元 返回0.01元
        deductionPrice = limit(deductionPrice);

        return deductionPrice;
    }

}
